/*function juedui(x,y,fn){

    return fn(x)+fn(y);//用fn()实现引入的函数的效果

}


console.log(juedui(-3,-5,Math.abs));//高阶函数结果为8


function pingfang(x){

    return x * x;

        }           //创建一个可以平方的函数

var arr  = [1,2,3,4,5,6]

console.log(arr.map(pingfang));//输出效果 数组里的数都被平方一遍

//也可以用一行代码将数组内数据类型改变

console.log(arr.map(String));//注意大小写



var arr = [1,2,3,4,5]       

function num(x,y){
    return x + y    
}           //创建一个相加的函数

console.log(arr.reduce(num)); //reduce对数组内的数进行累积使用函数


// [x1, x2, x3, x4].reduce(f) = f(f(f(x1, x2), x3), x4) 

*
console.log(typeof('555')); //输出string

console.log(typeof(555)); //输出number

*/

/* 练习 var arr = [1, 3, 5, 7, 9];



console.log( arr.reduce(function (x, y) {
    return x * y;
}));

*/

/* 练习 var arr = ['avd','sRiip','WWee']

function big(){

        for(let i =0 ; i < arr.length ; i++){

            var l = arr[i][0].toUpperCase()

        var lower = arr[i].substring(1).toLowerCase()

         arr[i]=`${l}${lower}`
        }

        console.log(arr);
}

big()
*/

/* var arr = [15,'44']

var a = arr.filter(
        function(x){
            return typeof(x) !== String

        }
    
) ;

console.log(a);
*/


/*var arr = ['a','b','c']

var r = arr.filter(function(num1,num2,num3){

        console.log(num1);
        console.log(num2);
        return true ;


})
*/
        //试试利用filter和回调函数给数组去重

var  arr = ['abc','abc','apple','banana','sql']

var a = arr.filter(function(num1,num2,num3){

       return arr.indexOf(num1) == num2



})

console.log(a);







